package com.skycode5.bean.util;

import java.rmi.ConnectException;
import java.sql.Connection;
import java.sql.DriverManager;

public class DBConnection {
    private String FileName;
    private int DBType;
    private Connection conn;
    private String MYSQLDriver;
    private String MYSQLURL;

    public DBConnection() {
        conn = null;
    }

    public Connection getConn() {
        DBType = 1;
        switch (DBType) {
            case 1:
                return (getConnToMySql());
            default:
                return null;
        }
    }

    private Connection getConnToMySql() {
        try {
            MYSQLDriver = "com.mysql.jdbc.Driver";
            MYSQLURL = "jdbc:mysql://localhost:3306/sky5" + "?useUnicode=true&characterEncoding=utf8";
            Class.forName(MYSQLDriver);
            conn = DriverManager.getConnection(MYSQLURL);
        } catch (Exception e) {
            e.printStackTrace();
        }

        return conn;
    }
}

